# Maintainer: David Runge <dvzrv@archlinux.org>

_name=crispy-bootstrap3
pkgname=python-crispy-bootstrap3
pkgver=2022.1
pkgrel=3
pkgdesc="Bootstrap3 template pack for django-crispy-forms"
arch=(any)
url="https://github.com/django-crispy-forms/crispy-bootstrap3"
license=(MIT)
depends=(
  python
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  python-django
  python-django-crispy-forms
  python-pytest
  python-pytest-django
)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha256sums=('f62729ed06976caf7fd5fd4fe009c0a702b0705db7765c2b486ba96c64341146')
b2sums=('2d74fad37ff5ccac41ed3765863ebac7ce3fca3f5b46879f53e7bed7655eedf075aaeb93d06e7597a5d46287e8ba08d79c04d8af523d585fe9e4997e4ab39904')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$site_packages:$PWD:$PYTHONPATH"
  pytest -vv tests
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 {CHANGELOG,README}.md -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
